from django.middleware.common import MiddlewareMixin
from utils.result import R
from utils.logutil import logging

import traceback

class ErrorMiddleware(MiddlewareMixin):

    def process_exception(self,request,exception):
        msg = traceback.format_exc()
        logging.error(msg)

        return R.server_error().to_json_response()